package com.example.admin.controller.web.system;

import java.util.Arrays;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.common.system.entity.RoleMenuEntity;
import com.example.common.system.service.RoleMenuService;
import com.example.common.util.PageUtils;
import com.example.common.core.response.AjaxResult;



/**
 * 角色和菜单关联表
 *
 * @author chen
 * @email 17635014889@163.com
 * @date 2022-09-21 15:07:55
 */
@RestController
@RequestMapping("/system/rolemenu")
public class RoleMenuController {
    @Autowired
    private RoleMenuService roleMenuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("system:rolemenu:list")
    public AjaxResult list(Page<RoleMenuEntity> page,RoleMenuEntity roleMenuEntity){
        PageUtils result = roleMenuService.queryPage(page,roleMenuEntity);

        return AjaxResult.success(result);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{roleId}")
    //@RequiresPermissions("system:rolemenu:info")
    public AjaxResult info(@PathVariable("roleId") Long roleId){
		RoleMenuEntity roleMenu = roleMenuService.getById(roleId);

        return AjaxResult.success(roleMenu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("system:rolemenu:save")
    public AjaxResult save(@RequestBody RoleMenuEntity roleMenu){
		roleMenuService.save(roleMenu);

        return AjaxResult.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("system:rolemenu:update")
    public AjaxResult update(@RequestBody RoleMenuEntity roleMenu){
		roleMenuService.updateById(roleMenu);

        return AjaxResult.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("system:rolemenu:delete")
    public AjaxResult delete(@RequestBody Long[] roleIds){
		roleMenuService.removeByIds(Arrays.asList(roleIds));

        return AjaxResult.success();
    }

}
